package com.itcast.demo_one.kotlin

fun main() {
    var man = Man("张三", 18)
    man.work("写代码")
    man.eat("苹果")
    man.show()
    man.sleep()
}

/**
 * 定义接口
 * - 方法
 * - 属性
 */
interface IPerson {
    // 1. 属性
    var name: String
    var age: Int

    // 2. 方法
    fun work(msg: String)
    fun eat(food: String)

    // 3. 方法(默认实现)
    fun show() {
        println("展示吧, 少年")
    }
}

interface ISleep {
    fun sleep()
}

class Man(override var name: String, override var age: Int): IPerson, ISleep {
    override fun work(msg: String) {
        println("姓名: $name, 工作: $msg")
    }

    override fun eat(food: String) {
        println("姓名: $name, 吃的食物: $food")
    }

    override fun sleep() {
        println("姓名: $name, 睡觉")
    }

}

class Woman(override var name: String, override var age: Int): IPerson {
    override fun work(msg: String) {
        println("姓名: $name, 工作: $msg")
    }

    override fun eat(food: String) {
        println("姓名: $name, 吃的食物: $food")
    }

}


















